package com.qingcheng.controller;

import com.qingcheng.entity.Result;
import com.qingcheng.pojo.order.OrderInfoSum;
import com.qingcheng.service.OrderInfoSumService;
import com.qingcheng.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("/orderinfosum")
public class OrderInfoSumController {

    @Autowired
    private OrderInfoSumService orderInfoSumService;

    @Autowired
    private OrderService orderService;

    @RequestMapping("/findorderinfo")
    public Result findorderinfo(){
        String date1= String.valueOf(LocalDate.now());
        String date2= String.valueOf(LocalDate.now().minusDays(1));
        String date3= String.valueOf(LocalDate.now().minusDays(2));
        String date4= String.valueOf(LocalDate.now().minusDays(7));
//        String date1 = "2019-05-26";
//        String date2 = "2019-05-25";
//        String date3 = "2019-05-23";
//        String date4 = "2019-05-24";
        OrderInfoSum orderInfoSum = orderInfoSumService.findOrderSum(date1,date2,date3,date4);
        orderInfoSum = orderService.findByStatus(orderInfoSum);
        return new Result(200,"统计成功",orderInfoSum);
    }
}
